Skip to content

Conversation

@scutifer
Copy link

@scutifer scutifer commented Nov 1, 2025

Adds a new gptel--get-user-instruction mirroring the existing one and writes a new entry to the transient menu.

Renames 'Add instruction' to 'Add system instruction' to make it clear where the instruction goes.

Added gptel--suffix-* that assembles parts of the prompt and are applied in transforms.

Adds a new gptel--get-user-instruction mirroring the existing
one and writes a new entry to the transient menu.

Renames 'Add instruction' to 'Add system instruction' to make it clear
where the instruction goes.

Added gptel--suffix-* that tries concating parts of the prompt and
apply in transforms.
@karthink
Copy link
Owner

karthink commented Nov 5, 2025

@scutifer Thanks for the PR. I don't understand its purpose though.

Can you give me more details and maybe an example or two?

@scutifer
Copy link
Author

scutifer commented Nov 8, 2025

@karthink Sure, apologies for the poorly worded PR.

From what I gathered, gptel prefers system prompts as instructions to the language model while user prompts are considered data that the instructions act upon. System prompts are set from gptel--system-message with optional next-message-only suffix from gptel--get-directive.

I wanted the next-message-only suffix feature for user messages too, where I'd add temporary "clarifications" just for that request. This PR is an attempt at duplicating the system directives logic to user messages too. (Models have a different affinity to system vs user prompts; commonly, system prompts are very strongly adhered to while user prompts are soft requests)

  • gptel--infix-add-user-instruction is nearly identical to gptel--infix-add-directive
  • gptel--get-user-instruction gets the additional suffix to apply during gptel--suffix-send
  • the existing code to concat region+instruction is replaced with more explicit normalisation logic that uses your transforms.
  • Helpers: gptel--suffix-join-nonempty joins args with 2 newlines; gptel--suffix-normalize-prompt uses join-nonempty to handle both cons cells and strings. gptel--suffix-insert-transform adds the given transform before gptel--transform-add-context. gptel--suffix-make-instruction-transform returns a transform to append instruction at send time. These exist so that we can handle 3 cases
    1. explicit prompt, instruction exists: instruction is merged immediately to the prompt
    2. implicit prompt from buffer, instruction exists: a transform is created to append instruction when sending it to the LLM
    3. explicit prompt, no instruction: use the prompt as-is, no transforms

(tbh there maybe a simpler solution but I couldn't think of any as I'm not very familiar with the codebase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants